<template>
    <div>
      <div class="header">
        <div class="h-left">
          <img @click="bac()" :src="'./static/lyl/back.png'" alt="">
          <span>下载</span>
        </div>
        <div class="h-right">
          <img @click="delate()" src="../../../assets/img/delete2.png" alt="">
        </div>
      </div>
      <ul class="h_ul">
        <li v-for="(item,index) in hisData" :key="index">
          <div class="h_left">
            <img :src="item.thumb" alt="加载失败">
          </div>
          <div class="h_right">
            <p>{{item.video_title}}</p>
            <!--<p>来自 {{item.author}}</p>-->
          </div>
        </li>
      </ul>
    </div>
</template>

<script>
  import {Dialog} from 'vant';
  import * as search from "../../../api/search.js"
    export default {
      name: "Dlone",
      data(){
        return {
          hisData:[]
        }
      },
      beforeMount(){
         // let parms2 = {video_id:1238,user_id:this.$store.state.user_id}
         // search.downloadVideo(parms2).then(res=>{
         //   console.log('下载',res)
         // })
        let parms = {user_id:this.$store.state.user_id}
        search.userDownload(parms).then(res=>{
          console.log('下载的数据',res)
          this.hisData = res.data;
        })
      },
      methods:{
        bac(){
          history.go(-1)
        },
        delate(){
          let parms = {user_id:this.$store.state.user_id}
          search.deleteDownload(parms).then(res=>{
            console.log('删除下载',res)
            if (res.code==0){
              Dialog.alert({
                message: res.msg
              });
              history.go(-1);
            }
          })
        }
      }
    }
</script>

<style scoped>
  .header{
    border-bottom: 2px solid #dcdcdc;
    padding: 20px 40px;
    display: flex;
    justify-content: space-between;
  }
  .header .h-left img{
    width: 22px;
    vertical-align: bottom;
    margin-right: 30px;
  }
  .header .h-left span{
    font-size: 36px;
  }
  .header .h-right img{
    width: 40px;
    height: 40px;
    align-self: center;
  }
  .h_ul{
    padding: 20px 40px;
  }
  .h_ul li{
    display: flex;
    padding-bottom: 25px;
  }
  .h_ul li:last-child{
    padding-bottom: 0;
  }
  .h_ul li .h_left{
    width: 50%;
    height: 190px;
    margin-right: 30px;
    background: #dcdcdc;
  }
  .h_ul li .h_left img{
    width: 350px;
    height: 190px;
  }
  .h_ul li .h_right{
    width: 50%;
    align-self: center;
    overflow: hidden;
  }
  .h_ul li .h_right p:nth-child(1){
    font-size: 24px;
    overflow: hidden;
    text-overflow:ellipsis;
    white-space: nowrap;
  }
  .h_ul li .h_right p:nth-child(2){
    font-size: 18px;
    line-height: 54px;
    color: #868686;
  }
</style>
